package com.yanqu.road.server.cmd.activity.xiaowurecall;

import com.yanqu.road.pb.activity.XiaowuRecallProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.xiaowuRecall.XiaowuRecallModule;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

@Cmd(code = Protocol.S_XIAOWU_RECALL_GET_USER_DATA,desc = "小舞回忆录获取玩家信息请求")
public class XiaowuGetDataCmd extends AbstractCommand {
    int activityId;

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception{
        XiaowuRecallProto.XiaowuRecallGetDataReqMsg reqMsg = XiaowuRecallProto.XiaowuRecallGetDataReqMsg.parseFrom(packet.getBytes());
        activityId = reqMsg.getActivityId();
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet)throws Exception{
        ret = player.getModule(XiaowuRecallModule.class).sendPlayerData();
    }

    @Override
    public void sendData(GamePlayer player){
        if (ret != 0){
            XiaowuRecallProto.XiaowuRecallGetDataRespMsg.Builder respMsg = XiaowuRecallProto.XiaowuRecallGetDataRespMsg.newBuilder();
            respMsg.setRet(ret);
            player.sendPacket(Protocol.U_XIAOWU_RECALL_SEND_DATA,respMsg);
        }
    }
}
